fix: enforce mode file restrictions for apply_diff tool (#4732) #4743
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Fixes #4732
This PR addresses the issue where mode file restrictions were being bypassed by the
apply_difftool. The problem occurred because the file permission check inisToolAllowedForModewas conditional on content parameters being present, allowing the tool to be approved before paths were validated.Changes Made
isToolAllowedForModeinsrc/shared/modes.tsto validate file paths as soon as they are availableargsparameter used bymultiApplyDiffToolFileRestrictionErrorwhen non-matching paths are providedapply_diffscenariosTesting
Verification of Acceptance Criteria
apply_difftool validates paths before executionChecklist
Important
Fixes mode file restriction bypass in
apply_diffby validating paths immediately inisToolAllowedForModeand updating tests accordingly.isToolAllowedForModeinmodes.tsnow validates file paths immediately, preventing bypassing of mode restrictions.argsinmultiApplyDiffTool.modes.test.tsto expectFileRestrictionErrorfor non-matching paths.apply_diffscenarios.apply_diffexecution.This description was created by
for e0699cd. You can customize this summary. It will automatically update as commits are pushed.